@extends('front.public_layout.layout')


@section('style')
    <link rel="stylesheet" href="{{asset('/front/css/author.css')}}">

    <style>

    </style>
@endsection

@section('content')
    <div class="middle-content author-info">

        <div class="auther-data">
            <div class="user-info">
                <div class="user-img">
                    <img src="{{ $userInfo['avatar_url'] }}" alt="">
                </div>
                <div class="nickname">{{ $userInfo['name'] }}</div>
                <div class="follow-btn" onclick="app_download_tip()">+ 点击关注</div>
            </div>


            <div class="num-data">
                <div class="data-item">
                    <div>{{ $authorArticleCount }}</div>
                    <div>文章发布数</div>
                </div>

                <div class="data-item">
                    <div>{{ $userInfo['fans_num'] }}</div>
                    <div>粉丝数</div>
                </div>
            </div>

        </div>

        <div class="author-article-list"></div>
        <div class="more-btn" onclick="article_list()">查看更多</div>

        <input type="hidden" name="author_id" value="{{ $authorId }}">
        <input type="hidden" name="is_admin" value="{{ $isAdmin }}">
    </div>
@endsection


@section('js')

    <script>

        var article_url = '{{ url('ajax_category_article_lists') }}';
        function article_list() {
            $.post(article_url, {
                _token: '{{ csrf_token() }}',
                is_admin: $('input[name="is_admin"]').val(),
                author_id: $('input[name="author_id"]').val(),
            }, function (data) {
                if (data.status == 1) {
                    if (data.data.next_page_url) {
                        article_url = data.data.next_page_url;
                        $('.more-btn').show();
                    } else {
                        $('.more-btn').hide();
                    }

                    var html = '';
                    $.each(data.data.data,function(index,item){
                        html += '<div class="article-item">';




                        if (item.list_img_url) {
                            html += '   <a class="article-img" href="'+'{{url('article/details')}}'+'/'+item.id+'">';
                            html += '       <img src="'+item.list_img_url+'">';
                            html += '   </a>';
                        }
                        html += '   <div class="article-info">';
                        html += '       <a class="title" href="'+'{{url('article/details')}}'+'/'+item.id+'">';

                        if (item.region_info) {
                            html += '       【'+item.region_info.region_name+'】';
                        }

                        html += '       '+item.article_title+'</a>';

                        html += '       <a class="author-info" href="'+'{{url('author')}}'+'/'+item.articles_author.id+'/1'+'">';
                        html += '           <div class="author">'+item.created_at+'</div>';
                        // html += '           <div class="time">'+item.created_at+'</div>';
                        html += '           <div class="right">';
                        html += '               <div class="zan">'+item.zan_num+'</div>';
                        html += '               <div class="read">'+item.read_num+'</div>';
                        html += '           </div>';
                        html += '       </a>';
                        html += '   </div>';
                        html += '</div>';

                    });

                    $('.author-article-list').append(html);


                } else {

                }
            }, 'json');
        }
        article_list();
    </script>
@endsection